package p.ithorns.framework.common.utils;

import java.util.Set;

/**
 * StringBox
 *
 * @author Ht.L
 * @date 2024-05-25 23:54
 * @since 1.0.0
 */
public class StringBox {

    private String origin;

    private StringBox(String origin) {
        this.origin = origin;
    }

    public static StringBox box(String origin) {
        return new StringBox(origin);
    }

    public StringBox trimAll() {
        this.origin = StringUtil.trimAllWhitespace(origin);
        return this;
    }

    public StringBox toUpperCase() {
        this.origin = origin.toUpperCase();
        return this;
    }

    public StringBox toLowerCase() {
        this.origin = origin.toLowerCase();
        return this;
    }

    public StringBox replace(String regex, String replacement) {
        this.origin = StringUtil.replaceAll(origin, regex, replacement);
        return this;
    }

    public StringBox camel() {
        this.origin = StringUtil.camel(new StringBuffer(origin)).toString();
        return this;
    }

    public StringBox underline() {
        this.origin = StringUtil.underline(new StringBuffer(origin)).toString();
        return this;
    }

    public String get() {
        return origin;
    }

    public Set<String> spilit2Set() {
        return StringUtil.split2Set(origin);
    }

    public String[] spilit() {
        return StringUtil.split(origin);
    }

}